<?php


namespace App\Transforms;


use App\Enum\CarEnum;
use App\Enum\DriverEnum;
use App\Enum\WithdrawEnum;
use App\Models\UploadFile;
use BobCoder\Construct\Foundation\Transform\TransformContract;

class WithdrawTransformer implements TransformContract
{

    public function transform($attributes)
    {
        return $attributes;
    }


    /**
     * 格式化数据
     * @param $list
     * @return mixed
     * @Author 姿势就是力量
     */
    public function transformList($list)
    {

        if (!$list) return $list;
        foreach ($list as &$item) {
             //   $item['status']=DriverEnum::withdraw($item['status']);

            if (isset($item['admin']) && $item['admin']) {
                $item['admin'] = $item['admin']['name'];
            }

            if (isset($item['driver']) && $item['driver']) {
              $item['real_name'] = $item['driver']['real_name']?$item['driver']['real_name']:"";
              $item['phone'] = $item['driver']['phone'];
            }else{
                $item['real_name'] = '';
                $item['phone'] ='';
            }
            unset($item['driver']);

            if (isset($item['wallet']) && $item['wallet']) {
                $item['account']=$item['wallet']['account'];
                $item['bank_name']=$item['wallet']['bank_name'];
                $item['account_name']=$item['wallet']['account_name'];
            }else{
                $item['type'] = '';
                $item['account']='';
                $item['bank_name']='';
                $item['account_name']='';
            }
            unset($item['wallet']);
        }

        return $list;
    }

}
